﻿@using viBook.Helpers
@using viBook.Models
@using Page = viBook.Models.Page
@helper InternetExplorer6Warning()
    {
    @:<!--[if lt IE 7]> <div style=' clear: both; height: 59px; padding:0 0 0 15px; position: relative;'> <a href="http://windows.microsoft.com/en-US/internet-explorer/products/ie/home?ocid=ie6_countdown_bannercode"><img src="http://www.theie6countdown.com/images/banners/warning_bar_0000_us.jpg" border="0" height="42" width="820" alt="You are using an outdated browser. For a faster, safer browsing experience, upgrade for free today." /></a></div> <![endif]-->
}
@helper ChapterCommentsToJavaScriptConverter(IList<ChapterComment> chapterComments, int userId)
    {
    @:[
    for (int i = 0; i < chapterComments.Count; i++)
    {
        if (i < chapterComments.Count - 1)
        {
    @:new Comment(@chapterComments[i].Id,@userId, '@Helpers.LegalNewLine(chapterComments[i].Content)','@chapterComments[i].CreatedDate.ToShortDateString()','@chapterComments[i].Vote',false,false,false),
        }
        else
        {
    @:new Comment(@chapterComments[i].Id,@userId, '@Helpers.LegalNewLine(chapterComments[i].Content)','@chapterComments[i].CreatedDate.ToShortDateString()','@chapterComments[i].Vote',false,false,false)
        }
    }
    @:]
}
@helper PagesToJavaScriptConverter(IList<Page> pages)
    {
    @:[
    for (int i = 0; i < pages.Count; i++)
    {
        Page currentPage = pages[i];
    @: new Picture(@currentPage.Id, '@currentPage.ImageSource', [
        for (int j = 0; j < currentPage.Tags.ToList().Count; j++)
        {
            Tag currentTag = currentPage.Tags.ToList()[j];
            if (j < currentPage.Tags.ToList().Count - 1)
            {
    @:new Tag('@currentTag.Position', '@currentTag.ConvertedText'),
            }
            else
            {
    @:new Tag('@currentTag.Position', '@currentTag.ConvertedText')
            }
        }
    @:])
        if (i < pages.Count - 1)
        {
    @:,
        }
    }
    @:]
}
@helper ContentTagsToJavaScriptConverter(List<ContentTag> contentTags)
    {
    @:[
    for (int i = 0; i < contentTags.Count; i++)
    {
        ContentTag contentTag = contentTags[i];
        if (i < contentTags.Count - 1)
        {
    @:new ContentTag(@contentTag.Id, '@contentTag.Name',@contentTag.NumberOfBook),
        }
        else
        {
    @:new ContentTag(@contentTag.Id, '@contentTag.Name',@contentTag.NumberOfBook)
        }
    }
    @:]
}
@helper TagsToJavaScriptConverter(List<Tag> tags)
    {
    @:[
    for (int i = 0; i < tags.Count; i++)
    {
        Tag tag = tags[i];
        if (i < tags.Count - 1)
        {
    @:new Tag(@tag.Id, '@tag.Position','@tag.ConvertedText'),
        }
        else
        {                              
    @:new Tag(@tag.Id, '@tag.Position','@tag.ConvertedText')
        }
    }
    @:]
}
@helper PageToJavaScriptConverter(Page page)
    {
    @:new Picture(@page.Id, '@page.ImageSource')
}

@helper BooksToJavaScriptConverter(List<Book> books)
    {
    @:[
    for (int i = 0; i < books.Count; i++)
    {
        Book book = books[i];
        if (i < books.Count - 1)
        {
    @:new Book(@book.Id, '@book.Title','@book.CoverUrl',@book.HasChapters.BooleanToJavascript(),@book.NumberOfPage,@book.NumberOfChapters,@book.NumberOfLikes,@book.NumberOfViews,@book.NumberOfComments),
        }
        else
        {                                                                                                  
    @:new Book(@book.Id, '@book.Title','@book.CoverUrl',@book.HasChapters.BooleanToJavascript(),@book.NumberOfPage,@book.NumberOfChapters,@book.NumberOfLikes,@book.NumberOfViews,@book.NumberOfComments)
        }
    }
    @:]
}
